package com.yimi.yinhepda.views.break_card;

import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.view.KeyEvent;
import android.view.View;
import android.widget.TextView;

import com.pda.ym.utils.SysInfo;
import com.pda.ym.base.BaseActivity;
import com.yimi.yinhepda.R;
import com.pda.ym.utils.ActivityStack;
import com.yimi.yinhepda.utils.Common;

/**
 * G7打开设备信息界面
 * @author 000432
 * @date 2018/5/29 0029
 */

public class BreakCardLocalInfoActivity extends BaseActivity {

    private TextView loginEmp;
    private TextView logingStatin;
    private TextView currentVersion;
    private TextView deviceId;
    private TextView et_worknum;
    private TextView mDeviceModle;

    @Override
    public String getPageName() {
        return "G7打开设备信息界面";
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_break_card_local_info);

        //校验设备型号
        String phoneModel = SysInfo.getInstance().getPhoneModel();
        if (phoneModel.equals(Common.DEV_MODEL)) {
            //横屏
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
        }

        loginEmp = (TextView) findViewById(R.id.login_emp);
        logingStatin = (TextView) findViewById(R.id.login_station);
        currentVersion = (TextView) findViewById(R.id.current_version);
        deviceId = (TextView) findViewById(R.id.device_id);
        et_worknum = (TextView) findViewById(R.id.et_worknum);
        mDeviceModle = (TextView) findViewById(R.id.device_modle);
        loginEmp.setText(sharedPreferUtil.getEmpName());
        logingStatin.setText(sharedPreferUtil.getDeptCode());
        currentVersion.setText(SysInfo.getInstance().getVersionName());
        deviceId.setText(SysInfo.getInstance().getImei());
        et_worknum.setText(sharedPreferUtil.getWorkNum());
        mDeviceModle.setText(SysInfo.getInstance().getPhoneModel());

        findViewById(R.id.ib_back).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                toBreakCardSettingActivity();
            }
        });

        findViewById(R.id.btn_exit_login).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                sharedPreferUtil.setBooleanValue(Common.PDT_DEV, false);
                ActivityStack.getInstance().exit();
            }
        });
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if ((keyCode == KeyEvent.KEYCODE_BACK)) {
            toBreakCardSettingActivity();
            return false;
        }
        return super.onKeyDown(keyCode, event);
    }

    private void toBreakCardSettingActivity() {
        toActivity(BreakCardSettingActivity.class);
        finish();
    }
}
